package pl.edu.uj.tcs.blef.protocol;

import java.io.PrintWriter;
import java.net.Socket;

import pl.edu.uj.tcs.blef.server.GlobalSettings;

/**
 * Client-Server protocol request /identify default handler.
 * @author Maciej Bendkowski
 *
 */
public class IdentifyRequestHandler implements RequestHandler {
	
	@Override
	public void handle(Request request, Socket socket) {
		System.out.println("Handling " + request.message + " request from " + socket.getInetAddress().getHostAddress());
		try {
			PrintWriter outputStream = new PrintWriter(socket.getOutputStream());
			String param[] = new String[1]; param[0] = "OK Identify " + GlobalSettings._SERVER_NAME_ + " at port " + socket.getLocalPort();
			new OKRequestFactory().build(param, new NullRequestHandler()).send(outputStream);
		} catch (Exception e) {}
	}
}
